package com.sl.ms.carriage.handler;

import cn.hutool.core.util.ObjectUtil;
import com.sl.ms.carriage.domain.constant.CarriageConstant;
import com.sl.ms.carriage.domain.dto.WaybillDTO;
import com.sl.ms.carriage.entity.CarriageEntity;
import com.sl.ms.carriage.service.CarriageService;
import org.checkerframework.checker.units.qual.C;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * description:
 *
 * @Author youhongwei
 * @Create 2025/6/23 20:06
 * @Version 1.0
 */
@Order(100)
@Component
public class SameCtiyChainHandler extends AbsCarriageChainHandler{

    @Resource
    private CarriageService carriageService;

    @Override
    public CarriageEntity doHandler(WaybillDTO waybillDTO) {


        CarriageEntity carriageEntity = null;
        if(ObjectUtil.equal(waybillDTO.getSenderCityId(),waybillDTO.getReceiverCityId())){
            carriageEntity = this.carriageService.findByTemplateType(CarriageConstant.SAME_CITY);
        }

        if(carriageEntity != null){
            return carriageEntity;
        }
        return doNextHandler(waybillDTO);
    }
}
